package com.tedu.ds.evaluationFeedback.controller;

import com.tedu.ds.base.response.JsonResult;
import com.tedu.ds.evaluationFeedback.pojo.dto.FeedbackQuery;
import com.tedu.ds.evaluationFeedback.pojo.dto.FeedbackSaveParam;
import com.tedu.ds.evaluationFeedback.pojo.entity.Feedback;
import com.tedu.ds.evaluationFeedback.pojo.vo.FeedbackPage;
import com.tedu.ds.evaluationFeedback.service.FeedbackService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequestMapping("/v1/feedback")
@RestController
@Api(tags = "评价与反馈管理")
public class FeedbackController {
    @Autowired
    private FeedbackService feedbackService;
    @ApiOperation("新增评价与反馈")
    @PostMapping("/save")
    public JsonResult save(@RequestBody FeedbackSaveParam param){
        feedbackService.save(param);
        return JsonResult.ok();
    }
    @ApiOperation("删除评价与反馈")
    @DeleteMapping("/delete/{id}")
    @ApiImplicitParam(name = "id", value = "评价与反馈ID", required = true)
    public JsonResult delete(@PathVariable Long id){
        feedbackService.deleteById(id);
        return JsonResult.ok();
    }
    @ApiOperation("修改评价与反馈")
    @PostMapping("update")
    public JsonResult update(@RequestBody FeedbackSaveParam param){
        feedbackService.save(param);
        return JsonResult.ok();
    }
    @ApiOperation("查询评价与反馈")
    @PostMapping("/select")
    public JsonResult select(@RequestBody FeedbackQuery query){
        FeedbackPage page =feedbackService.select(query);
        return JsonResult.ok(page);
    }
}
